# Maintainer: Alexey Pavlov <alexpux@gmail.com>
# Contributor: Tim S. <stahta01@gmail.com>

_realname=kicad-doc
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}-ca"
         "${MINGW_PACKAGE_PREFIX}-${_realname}-de"
         "${MINGW_PACKAGE_PREFIX}-${_realname}-en"
         "${MINGW_PACKAGE_PREFIX}-${_realname}-es"
         "${MINGW_PACKAGE_PREFIX}-${_realname}-fr"
         "${MINGW_PACKAGE_PREFIX}-${_realname}-id"
         "${MINGW_PACKAGE_PREFIX}-${_realname}-it"
         "${MINGW_PACKAGE_PREFIX}-${_realname}-ja"
         # "${MINGW_PACKAGE_PREFIX}-${_realname}-nl"
         "${MINGW_PACKAGE_PREFIX}-${_realname}-pl"
         "${MINGW_PACKAGE_PREFIX}-${_realname}-ru"
         "${MINGW_PACKAGE_PREFIX}-${_realname}-zh")
# https://gitlab.com/kicad/services/kicad-doc/-/jobs/9565954616/artifacts/browse/archive/
_job_id='9565954616' # this is needed to change for new version
pkgver=9.0.1
pkgrel=1
pkgdesc="Documentation for KiCad (mingw-w64)"
arch=(any)
mingw_arch=('ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: kicad'
)
url="https://www.kicad.org/"
license=("spdx:GPL-3.0-or-later OR CC-BY-3.0")
makedepends=()
optdepends=("${MINGW_PACKAGE_PREFIX}-kicad-meta"
            "${MINGW_PACKAGE_PREFIX}-kicad")

# Use the more current build artifact from the release tag instead:
# https://gitlab.com/kicad/services/kicad-doc/-/artifacts
source=("${_realname}-${pkgver}.tar.gz::https://gitlab.com/kicad/services/kicad-doc/-/jobs/${_job_id}/artifacts/raw/archive/kicad-doc-unknown.tar.gz")
sha256sums=('978188d79fab3c14df0a4f1a66e80b449dfb3779ed652b6b209e1df4d3060efb')

build_lang() {
  cd "${srcdir}/kicad-doc-unknown/share/doc/kicad/help"
  mkdir -p "${pkgdir}${MINGW_PREFIX}/share/doc/kicad/help/"
  cp -R ${langid} "${pkgdir}${MINGW_PREFIX}/share/doc/kicad/help/"
}

for _n in ${pkgname[@]}; do
  eval "package_${_n}() {
    langid="${_n#${MINGW_PACKAGE_PREFIX}-${_realname}-}" build_lang
  }"
done
